﻿package mortal.game.view.copy.wine.util
{
    import Message.DB.Tables.*;
    import Message.Public.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.scene3D.layer3D.utils.*;
    import mortal.game.scene3D.player.entity.*;
    import mortal.game.view.chat.*;
    import mortal.mvc.core.*;

    public class WinePartySpeakUtil extends Object
    {
        public static var mora:int = 2;
        public static var drunk:int = 3;
        private static var totalPro:int = 100;
        private static var typeObj:Object;

        public function WinePartySpeakUtil()
        {
            return;
        }// end function

        private static function initInfo() : void
        {
            var _loc_1:Array = null;
            var _loc_2:Array = null;
            var _loc_3:Array = null;
            var _loc_4:TMaskName = null;
            var _loc_5:Array = null;
            if (typeObj == null)
            {
                _loc_1 = MaskNameConfig.instance.getInfoByType(2);
                _loc_2 = MaskNameConfig.instance.getInfoByType(3);
                _loc_3 = _loc_1.concat(_loc_2);
                if (_loc_3)
                {
                    typeObj = {};
                    for each (_loc_4 in _loc_3)
                    {
                        
                        if (!typeObj[_loc_4.type + "-" + _loc_4.sex])
                        {
                            typeObj[_loc_4.type + "-" + _loc_4.sex] = [];
                        }
                        _loc_5 = typeObj[_loc_4.type + "-" + _loc_4.sex];
                        _loc_5.push(_loc_4);
                    }
                }
            }
            return;
        }// end function

        public static function speakByType(param1:int, param2:SEntityId = null) : void
        {
            if (param2)
            {
                if (EntityUtil.equal(RolePlayer.instance.entityInfo.entityInfo.entityId, param2) == false)
                {
                    return;
                }
            }
            var _loc_3:* = getSpeakStr(param1);
            if (_loc_3 == null)
            {
                return;
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.ChatSend, {content:_loc_3, area:ChatArea.Scene, isSystem:true}));
            return;
        }// end function

        public static function getSpeakStr(param1:int) : String
        {
            initInfo();
            if (typeObj == null)
            {
                return null;
            }
            var _loc_2:* = RolePlayer.instance.entityInfo.entityInfo.sex;
            var _loc_3:* = typeObj[param1 + "-" + _loc_2];
            if (_loc_3 == null)
            {
                return null;
            }
            var _loc_4:* = Math.random() * _loc_3.length;
            return (_loc_3[_loc_4] as TMaskName).name;
        }// end function

    }
}
